<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use DB;

class Job extends Model {

    protected $table = 't_job';
    protected $guarded  = ['id'];
    protected $primaryKey = 'jobid';
    public $timestamps = false;

    static function getKinds(){
        return DB::table("t_category")->select('categoryid','name','parentid')->get();
    }

    public function category(){
        return $this->belongsTo('App\Category', 'categoryid');
    }

    public function poster()
    {
        return $this->belongsTo('App\User', 'userid');
    }

    public function hasPoster($id){
        return "" == DB::table('admins')->where('id',$id)->first() ? false : true;
    }
}
